<?php
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

jimport('joomla.form.formfield');

// The class name must always be the same as the filename (in camel case)
class JFormFieldTelefone extends JFormField {

	//The field class must know its own type through the variable $type.
	protected $type = 'Telefone';

	//public function getLabel() {
		// code that returns HTML that will be shown as the label
	//}

	public function getInput() {
		// Initialize some field attributes.
		$size		= $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : '';
		$maxLength	= $this->element['maxlength'] ? ' maxlength="'.(int) $this->element['maxlength'].'"' : '';
		$class		= $this->element['class'] ? ' class="'.(string) $this->element['class'].' inputbox"' : '';
		$auto		= ((string) $this->element['autocomplete'] == 'off') ? ' autocomplete="off"' : '';
		$readonly	= ((string) $this->element['readonly'] == 'true') ? ' readonly="readonly"' : '';
		$disabled	= ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';

		// Initialize JavaScript field attributes.
		$onchange	= $this->element['onchange'] ? ' onchange="'.(string) $this->element['onchange'].'"' : '';
		$onkeyup	= " onkeyup=\"this.value=this.value.replace(/[^\\d]/,'')\"";

		return '<input type="text" name="'.$this->name.'" id="'.$this->id.'"' .
			' value="'.htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8').'"' .
			$auto.$class.$readonly.$disabled.$size.$maxLength.$onchange.$onkeyup.' style="width:none;" /> somente n&uacute;meros';
	}
}